package org.eyeTopLight.po;

import lombok.Data;
import org.eyeTopLight.constant.ConstantUtil;
import org.eyeTopLight.po.initEntity.Goods;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class AccessoryGoods implements Goods {

    private Integer accessoryGoods_id;
    private Date accessoryGoods_updateDate;
    private String accessoryGoods_name;
    private String accessoryGoods_desc;
    private String accessoryGoods_category;
    private String accessoryGoods_imageUrl;
    private Double accessoryGoods_price;
    private Integer accessoryGoods_store;
    private Integer accessoryGoods_onShelf;
    private Integer accessoryGoods_imageCount;
    private Integer accessoryGoods_salesMonth;
    private Integer accessoryGoods_salesAll;
    private String accessoryGoods_detailsImageUrl;
    private Integer accessoryGoods_detailsImageCount;

    @Override
    public String getImageUrlAtIndex(Integer index){
        String[] imageUrls = accessoryGoods_imageUrl.split(ConstantUtil.SEPARATOR_SYMBOL);
        if (imageUrls == null || index >= imageUrls.length){
            return null;
        }
        return imageUrls[index];
    }

    @Override
    public String getSymbol(){
        return "accessory";
    }

    @Override
    public String getGoods_updateDate(){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        String dateTime = formatter.format(getAccessoryGoods_updateDate());
        return dateTime;
    }

    @Override
    public String getGoods_imageUrl(){
        return getAccessoryGoods_imageUrl();
    }
}
